package com.woniuxy.aimcpserver.tools;

import com.woniuxy.aimcpserver.entity.food;
import com.woniuxy.aimcpserver.mapper.FoodMapper;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.ai.tool.annotation.ToolParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FoodService {
    @Autowired
    private FoodMapper foodMapper;

    @Tool(description = "获取所有食物信息", name = "foodQuery")
    public List<food> getFood() {
        return foodMapper.getAllFood();
    }
    @Tool(description = "新增套餐信息", name = "foodQuery2")
    public String addFood(@ToolParam (description = "食物名称")String FoodName,
                          @ToolParam(description = "食物介绍")String foodIntro,
                          @ToolParam(description = "食物价格")Integer price,
                          @ToolParam(description = "食物热量")Integer kcal) {
        food f=new food(null, FoodName, foodIntro, price, kcal, null);
        foodMapper.addFood(f);
     return "新增成功" +f.toString();
    }
    @Tool(description = "调用内部API删除套餐信息", name = "foodQuery3")
    public String deleteFood(@ToolParam (description = "食物ID")Integer foodId) {
        foodMapper.deleteFood(foodId);
        return "删除成功";
    }

    @Tool(description = "打开食堂页面", name = "foodQuery4")
    public String goToFood() {
        return "localhost:8888/DiningCanteens";
    }


}
